#include <iostream>
#include <string>
#include <vector>

using namespace std;

// 100.00 %
class Solution
{
  private:
    vector<string> res;
    bool Check(string s)
    {
        if (s.length() == 0 || s[0] == '0' && s.length() != 1)
            return false;
        int sum = 0;
        for (int i = 0; i < s.length(); i++)
        {
            sum = sum * 10 + s[i] - '0';
        }
        if (sum >= 0 && sum <= 255)
        {
            return true;
        }
        return false;
    }
    void restoreIp(string ip, int index, string s)
    {
        if (index == 4)
        {
            if (Check(ip))
            {
                res.push_back(s + ip);
            }
            return;
        }
        for (int i = 1; i < ip.length(); i++)
        {
            string str = ip.substr(0, i);
            if (Check(str))
            {
                restoreIp(ip.substr(i), index + 1, s + str + ".");
            }
            else
            {
                break;
            }
        }
    }

  public:
    vector<string> restoreIpAddresses(string s)
    {
        string str = "";
        restoreIp(s, 1, str);
        return res;
    }
};

int main()
{
    string s = "25525511135";
    vector<string> myVector = Solution().restoreIpAddresses(s);
    for (int i = 0; i < myVector.size(); i++)
    {
        cout << myVector[i] << endl;
    }
    return 0;
}
